package models

import (
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
	"user_manage/conf"
)

var Rdb *redis.Client
var Ctx = context.Background()

func RedisLink() {
	address := fmt.Sprintf("%s:%s", conf.AppConfigs.Redis.Host, conf.AppConfigs.Redis.Port)
	rdb := redis.NewClient(&redis.Options{
		Addr:     address,
		Password: conf.AppConfigs.Redis.Pass, // no password set
		DB:       0,                          // use default DB
	})

	err := rdb.Set(Ctx, "key", "value", 0).Err()
	if err != nil {
		panic(err)
	}
	fmt.Println("redis预处理完成")
}
